@extends('layouts.header')
@section('content')
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 检测业务 <span class="c-gray en">&gt;</span> 结果录入
        <a class="btn btn-primary radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <div class="page-container">
        <div class="cl mb-10 bg-1 bk-gray">
            <span class="c-red">注意：审批后退样前的批次可见</span>
        </div>
        <table class="table table-border table-bordered table-hover table-bg table-responsive" id="datatable">
            <thead>
            <tr class="text-c">
                <th>批次编号</th>
                <th>客户名称</th>
                <th>受理人</th>
                <th>受理时间</th>
                <th>完成期限</th>
                <th>批次状态</th>
                {{-- <th>任务总量</th> --}}
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach ($data as $val)
                @if($val->third_name)
                <tr class="text-c">
                    <td>{{ $val->batchNum }}</td>
                    <td>{{ $val->client_name }}</td>
                    <td>{{ $val->creator }}</td>
                    <td>{{ $val->created_at }}</td>
                    <td>{{ $val->deadline ? $val->deadline : '/' }}</td>
                    <td>
                        <span class="badge badge-{{$dbStat['status_badge'][$val->status]}} radius">{{$dbStat['status'][$val->status]}}</span>
                    </td>
                    {{-- <td>{{ $val->sum_count }}</td> --}}
                    <td class="text-l" >
                        <a class="ml-5 btn btn-primary-outline radius size-MINI" href="samples?id={{$val->id}}&client_name={{ $val->client_name }}">点击进入</a>
                        <a class="btn btn-primary-outline radius size-MINI " href="javascript:;" onclick="download_report({{ $val->id }})"><i class="Hui-iconfont">&#xe640;</i>检测报告</a>
                        <a class="btn btn-primary-outline radius size-MINI " href="javascript:;" onclick="download_original({{ $val->id }})"><i class="Hui-iconfont">&#xe640;</i>原始记录</a>
                        <a class="btn btn-primary size-MINI radius" onclick="toThird({{$val->id}},{{$val->third_id}})"><i class="Hui-iconfont">&#xe642;</i>{{$val->third_name}}</a>
                    </td>
                </tr>
                @endif
            @endforeach
            </tbody>
        </table>
        <div class="f-r mt-10"><input class="input-text" type="text" value="" placeholder="指定页码" id="jumpPage"/></div>
    </div>

    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript">
        $(function () {
            $('#datatable').DataTable({
                order:[[0,'desc']],
                language: {
                    url: '/admin/lib/datatables/dataTables_Chinese_Lang.json'
                },
            })
        })
        /* 跳转页面 */
        function jump_page(url, id) {
            location.href = url + '?id=' + id;
        }

        /*下载报告*/
        function download_report(id) {
            // window.open('/{{config('constant.name_admin')}}/exportReport/export?id=' + id, '_blank');
            layer.confirm('下载excel还是pdf？',{btn:['excel','pdf'],btn1:function () {
                window.open('/{{config('constant.name_admin')}}/exportReport/export?id=' + id, '_blank');
            },btn2:function(){
                window.open('/{{config('constant.name_admin')}}/exportReport/export?toPdf=1&id=' + id, '_blank');
            }})
        }

         /*上传到第三方系统*/
        function toThird(id,third_id) {
            ajax('post','toThird',{contract_id:id,third_id:third_id});
        }

        /*下载原始记录*/
        function download_original(id) {
            window.open('/{{config('constant.name_admin')}}/exportReport/origin?contract_id=' + id, '_blank');
        }

    </script>
@endsection